<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<% 
//String t_i=request.getParameter("task_id");
String t_name=request.getParameter("task_name");
String p_i=request.getParameter("project");
String summary=request.getParameter("summary");
String t_status=request.getParameter("status");
String t_type=request.getParameter("type");
String t_s_date=request.getParameter("s_date");
String t_e_date=request.getParameter("e_date");
//int p_id=Integer.parseInt(p_i);
//int t_id=Integer.parseInt(t_i);
int ab;
%>


<%
//String query1="insert into task values("+t_id+","+"'"+t_name+"'"+","+p_id+","+"'"+summary+"'"+","+"'"+t_status+"'"+","+"'"+t_type+"'"+","+"'"+t_s_date+"'"+","+"'"+t_e_date+"'"+")";
String query1="select distinct(project_id) from project where name='"+p_i+"'";
Connection db_conn1 = null;
Statement statement1 = null;
PreparedStatement pstmt1;
ResultSet rs1;
try{
Class.forName("com.mysql.jdbc.Driver");
String url= "jdbc:mysql://localhost:3306/db";
db_conn1 = DriverManager.getConnection( url,"root", "root" );
statement1 = db_conn1.createStatement();
rs1=statement1.executeQuery(query1);
while(rs1.next())
    {
        String ids=rs1.getString("project_id");
        int p_id=Integer.parseInt(ids);
        //out.println(ids);
        }
    
db_conn1.close();
} catch(SQLException e){
e.printStackTrace();
out.println("sql not found");
out.println(e);
} catch(ClassNotFoundException e){
e.printStackTrace();
out.println(e);
}
%>            




<%
String query="insert into task(task.name,task.project_id,task.summary,task.status,task.type,task.start_date,task.estimated_date) values('"+t_name+"','"+p_id+"','"+summary+"','"+t_status+"','"+t_type+"','"+t_s_date+"','"+t_e_date+"')";
Connection db_conn = null;
Statement statement = null;
PreparedStatement pstmt;
ResultSet rs;
try{
Class.forName("com.mysql.jdbc.Driver");
String url= "jdbc:mysql://localhost:3306/db";
db_conn = DriverManager.getConnection( url,"root", "root" );
statement = db_conn.createStatement();
statement.executeUpdate(query);

db_conn.close();
} catch(SQLException e){
e.printStackTrace();
out.println("sql not found");
out.println(e);
} catch(ClassNotFoundException e){
e.printStackTrace();
out.println(e);
}
%>            



